{include file='common/head'}
<body>
<div class="x-body">
    <form class="layui-form" method="post"  enctype="multipart/form-data">
		<div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red">*</span>主叫用户
            </label> 
            <div class="layui-input-inline">
                <select name="zhujiao" id="jname"  style="width:96px; " lay-verify="required">
				{volist name="rs" id="rs"}
				 <option value=""></option>
				 <option value="{$rs.uid}">{$rs.uname}</option>
			    {/volist}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red">*</span>被叫用户
            </label>
            <div class="layui-input-inline">
                <select name="beijiao" id="j"  style="width:96px; " lay-verify="required">
                    {volist name="res" id="res"}
                    <option value=""></option>
                    <option value="{$res.uid}">{$res.uname}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="bohaoadd" lay-submit="">
               提交
            </button>
        </div>
    </form>
</div>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;
        //自定义验证规则
        form.verify({
            nikename: function(value){
                if(value.length < 5){
                    return '昵称至少得5个字符啊';
                }
            }
            ,pass: [/(.+){6,12}$/, '密码必须6到12位']
            ,repass: function(value){
                if($('#L_pass').val()!=$('#L_repass').val()){
                    return '两次密码不一致';
                }
            }
        });
        //监听提交
        form.on('submit(bohaoadd)', function(data){
            //console.log(data);
            var url="";
            $.ajax({
                type: "post",
                async:false,
                url: "{:url('index/xinxi/bohaoadd')}",
                data: data.field,
                dataType:'json',
                success:function (res) {
                    /*layer.msg('添加成功！');
                    setTimeout(function () {
                        location.reload();
                    }, 1000);*/
                    //发异步，把数据提交给php
                    layer.alert("增加成功", {icon: 6},function () {
                    //获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                     });
                    setTimeout(function () {
                        window.parent.location.reload();//刷新父级窗口
                    }, 1000);
                    return false;
                }
            })
            return false;
        });


    });
</script>
</body>

</html>